package com.tengju.data.domain.model.user;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Value;

/**
 * @author chenhang
 * @Date 2021/1/21
 */
@Getter
@AllArgsConstructor
public class UserStarFeature {

    UserIdCode idCode;
    StarLevelEnum starLevel;
    StarLevelEnum inviteStarLevel;
    Integer tag;

    //星级老用户享受最高16%补贴
    public static final Integer STAR_SPECIAL_USER_TAG = 1;

    public UserStarFeature(Long idCode) {
        this.idCode = UserIdCode.of(idCode);
        this.starLevel = StarLevelEnum.NONE;
        this.inviteStarLevel = StarLevelEnum.NONE;
        this.tag = 0;
    }

    public boolean isMeetTag(Integer tagId) {
        return (tag & tagId) == 1;
    }

    public String getTagDesc() {
        StringBuilder sb = new StringBuilder();
        if (isMeetTag(STAR_SPECIAL_USER_TAG)) {
            sb.append("#特批");
        }
        if (starLevel == StarLevelEnum.NONE && inviteStarLevel != StarLevelEnum.NONE) {
            sb.append("#保留");
        }
        return sb.toString();
    }
}
